# -*- coding: utf8 -*-
import unittest
from item import Item
from equipment import Equipment
from player import Player
class TeatItem(unittest.TestCase):
    '''武器和道具的测试用例'''
    def test_useItem(self):
        ppl = Player(mhp=10,hp=3)
        ppl2 = Player(mhp=10,hp=8)
        ppl.mround = 2 
        ppl2.mround = 2
        item = Item(hp=3,name='血瓶')
        item2 = Item(hp=3,name='血瓶')
        ppl.useItem(item)
        ppl2.useItem(item2)
        self.assertEqual(ppl.hp,6)
        self.assertEqual(ppl.mhp,10)
        self.assertEqual(ppl2.hp,10)
        self.assertEqual(ppl2.mhp,10)
    def test_empoison(self):
        item = Item(name='毒药',hp=-5)
        ppl = Player(mhp=50,hp=50)
        ppl.mround = 2
        ppl.useItem(item)
        self.assertEqual(ppl.hp,45)
    def test_equip(self):
        ppl = Player(mhp=10,hp=10)
        ppl2 = Player(mhp=10,hp=10)
        sword = Equipment(atk=10)
        gun = Equipment(atk=20,lv=5)
        ppl.mround = 2 
        ppl2.mround = 2
        ppl.equip(sword)
        self.assertEqual(ppl.newAtk,20)
        ppl2.equip(gun)
        self.assertEqual(ppl2.equip(gun),False)
        self.assertEqual(ppl2.newAtk,10)
        ppl2.equip(sword)
        self.assertEqual(ppl2.equip(gun),False)
        self.assertEqual(ppl2.newAtk,10)   	
if __name__ == '__main__':
    unittest.main()
